package cn.cy.domain.DTO;

import cn.cy.domain.Const.ResponseConst;
import lombok.Data;

/**
 * @Author: Xucranger
 * @Date: 22/5/2 9:18
 */

@Data
public class ResultDTO<T> {
    protected Integer CODE;
    protected String msg;
    protected Boolean success;
    protected T data;

    public ResultDTO(){

    }



    public ResultDTO(Integer CODE, String msg, Boolean success) {
        this.CODE = CODE;
        this.msg = msg;
        this.success = success;
    }

    public ResultDTO(Integer CODE,String msg){
        this.msg = msg;
        this.CODE = CODE;
    }
    //根据const的key来确定
    public ResultDTO(String key,T data){

        ResultDTO resultDTO = new ResponseConst().getByKey(key);
        this.setData(data);
        this.setCODE(resultDTO.getCODE());
        this.setMsg(resultDTO.getMsg());
        this.setSuccess(resultDTO.getSuccess());

    }
    public ResultDTO(String key){
        ResultDTO resultDTO = new ResponseConst().getByKey(key);
        this.setSuccess(resultDTO.getSuccess());
        this.setMsg(resultDTO.getMsg());
        this.setCODE(resultDTO.getCODE());
    }

}
